﻿/*
 * doctor的业务逻辑层
 * */
using System;
using System.Collections.Generic;
using System.Text;
using WH.NurseSys.DAL;
using WH.NurseSys.Model;

namespace WH.NurseSys.BLL
{
    public class DoctorBLL
    {
        DoctorDAL doctorDAL = new DoctorDAL();

        public bool Insert(Doctor doctor)
        {
            return doctorDAL.Insert(doctor);
        }

        public bool Delete(Guid id)
        {
            return doctorDAL.Delete(id);
        }

        public List<Doctor> GetList()
        {
            return doctorDAL.GetList();
        }

        //按查询用户名/昵称返回分页列表
        public List<Doctor> GetPagedList(int pageIndex,int pageSize,string query)
        {
            return doctorDAL.GetPagedList(pageIndex, pageSize, query);
        }

        //按id获取用户信息
        public Doctor GetById(Guid id)
        {
            return doctorDAL.GetById(id);
        }

        public bool Exist(string username)
        {
            if (doctorDAL.GetByUsername(username) == null)
                return false;
            else
                return true;
        }

        public bool Update(Doctor doctor)
        {
            return doctorDAL.Update(doctor);
        }

        //登录
        public Doctor Login(string username, string pwd,out int code)
        {
            Doctor doctor = doctorDAL.GetByUsername(username);
            if (doctor == null)
            {
                code=2;
                return null;
            }
            if (doctor.Pwd != pwd)
            {
                code = 3;
                return null;
            }
            code = 1;
            return doctor;
        }
    }
}
